package clientGUI.userPanels;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.JButton;
import clientGUI.userPanels.Controllers.CommiteePanelController;

import clientserver.Client;

import javax.swing.ButtonGroup;


public class CommiteePanel extends UPanel implements ActionListener {

 private CommiteePanelController c;
 private boolean state;
 private JRadioButton rdbtnApprove;
 private JRadioButton addInfo;
 private JRadioButton deny;
 private JTextArea additionalInfo;
 private JButton btnSubmit;

 private final ButtonGroup buttonGroup = new ButtonGroup();
	
	public CommiteePanel(int id, Client cl) {
		setLayout(null);
		c= new CommiteePanelController(id, cl);
		 rdbtnApprove = new JRadioButton("Approve");
		 buttonGroup.add(rdbtnApprove);
		rdbtnApprove.setBounds(6, 49, 183, 23);
		add(rdbtnApprove);
		rdbtnApprove.addActionListener(new ActionListener() {
			
			
		public void actionPerformed(ActionEvent e)
		{
			state = rdbtnApprove.isSelected();
			if(state)
				c.UpdateRequestState();
			
		}
		});
		
		 addInfo = new JRadioButton("Request Additional info");
		 buttonGroup.add(addInfo);
		addInfo.setBounds(6, 68, 183, 23);
		add(addInfo);
		addInfo.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent e)
			{
				state = addInfo.isSelected();
				if(state)
				{
					additionalInfo.setVisible(true);
				       btnSubmit.setVisible(true);
				}
				
			}
		});
		
		 deny = new JRadioButton("Deny and close");
		 buttonGroup.add(deny);
		deny.setBounds(6, 88, 183, 23);
		add(deny);
		deny.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) 
			{
				state = deny.isSelected();
				if(state)
					c.UpdateRequestState();	
				
			}
		});
		
		 additionalInfo = new JTextArea();
		additionalInfo.setBounds(195, 54, 225, 98);
		add(additionalInfo);
		additionalInfo.setVisible(false);
		
		
		JLabel lblCommiteePerspective = new JLabel("COMMITEE PERSPECTIVE");
		lblCommiteePerspective.setBounds(144, 11, 185, 14);
		add(lblCommiteePerspective);
		
		 btnSubmit = new JButton("SUBMIT");
		btnSubmit.setBounds(265, 164, 89, 23);
		add(btnSubmit);
		
		JButton btnMainMenu = new JButton("Main Menu");
		btnMainMenu.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				myframe.SetMainUserPanel();
			}
		});
		btnMainMenu.setBounds(35, 244, 89, 23);
		add(btnMainMenu);
		btnSubmit.setVisible(false);
		
		
		btnSubmit.addActionListener(new ActionListener() {
			

			public void actionPerformed(ActionEvent e) 
			{
				
					c.sendinfo(additionalInfo.getText());
					additionalInfo.setVisible(false);
				       btnSubmit.setVisible(false);
				
			}		
			});

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	}
}
	
	

	
	